Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@aws-cdk/aws-events
Advanced tools
@aws-cdk/aws-events is an AWS Cloud Development Kit (CDK) library that allows you to define and manage Amazon EventBridge resources using code. EventBridge is a serverless event bus that makes it easier to build event-driven applications by connecting application data from your own applications, integrated Software-as-a-Service (SaaS) applications, and AWS services.
Creating an Event Bus
This code sample demonstrates how to create a new EventBridge event bus using the AWS CDK. The event bus can be used to receive and route events.
const events = require('@aws-cdk/aws-events');
const cdk = require('@aws-cdk/core');
const app = new cdk.App();
const stack = new cdk.Stack(app, 'EventBusStack');
const eventBus = new events.EventBus(stack, 'MyEventBus', {
eventBusName: 'my-event-bus'
});
app.synth();
Creating a Rule
This code sample demonstrates how to create an EventBridge rule that triggers when an EC2 instance changes state to 'running'. The rule targets a Lambda function.
const events = require('@aws-cdk/aws-events');
const targets = require('@aws-cdk/aws-events-targets');
const cdk = require('@aws-cdk/core');
const app = new cdk.App();
const stack = new cdk.Stack(app, 'EventRuleStack');
const rule = new events.Rule(stack, 'MyRule', {
eventPattern: {
source: ['aws.ec2'],
detailType: ['EC2 Instance State-change Notification'],
detail: {
state: ['running']
}
}
});
rule.addTarget(new targets.LambdaFunction(myLambdaFunction));
app.synth();
Scheduling Events
This code sample demonstrates how to create a scheduled EventBridge rule that triggers every 5 minutes. The rule targets a Lambda function.
const events = require('@aws-cdk/aws-events');
const targets = require('@aws-cdk/aws-events-targets');
const cdk = require('@aws-cdk/core');
const app = new cdk.App();
const stack = new cdk.Stack(app, 'ScheduledEventStack');
const rule = new events.Rule(stack, 'MyScheduledRule', {
schedule: events.Schedule.rate(cdk.Duration.minutes(5))
});
rule.addTarget(new targets.LambdaFunction(myLambdaFunction));
app.synth();
The aws-sdk package is the official AWS SDK for JavaScript, which provides a comprehensive set of tools for interacting with AWS services, including EventBridge. Unlike @aws-cdk/aws-events, which is used for defining infrastructure as code, aws-sdk is used for making API calls to AWS services.
The serverless framework is a popular open-source framework for building and deploying serverless applications. It supports AWS Lambda and EventBridge, among other services. While @aws-cdk/aws-events focuses on infrastructure as code, serverless provides a higher-level abstraction for deploying serverless applications.
Pulumi is an infrastructure as code tool that supports multiple cloud providers, including AWS. It allows you to define and manage cloud resources using familiar programming languages. Pulumi can be used to manage EventBridge resources similarly to @aws-cdk/aws-events, but it offers a different approach and supports multiple clouds.
Amazon CloudWatch Events delivers a near real-time stream of system events that describe changes in AWS resources. For example, an AWS CodePipeline emits the State Change event when the pipeline changes it's state.
The EventRule
construct defines a CloudWatch events rule which monitors an
event based on an event
pattern
and invoke event targets when the pattern is matched against a triggered
event. Event targets are objects that implement the IEventTarget
interface.
Normally, you will use one of the source.onXxx(name[, target[, options]]) -> EventRule
methods on the event source to define an event rule associated with
the specific activity. You can targets either via props, or add targets using
rule.addTarget
.
For example, to define an rule that triggers a CodeBuild project build when a commit is pushed to the "master" branch of a CodeCommit repository:
const onCommitRule = repo.onCommit('OnCommitToMaster', project, 'master');
You can add additional targets, with optional input
transformer
using eventRule.addTarget(target[, input])
. For example, we can add a SNS
topic target which formats a human-readable message for the commit.
For example, this adds an SNS topic as a target:
onCommitRule.addTarget(topic, {
template: 'A commit was pushed to the repository <repo> on branch <branch>',
pathsMap: {
branch: '$.detail.referenceName',
repo: '$.detail.repositoryName'
}
});
0.19.0 (2018-12-04)
ecr.RepositoryRef
has been replaced by ecr.IRepository
, which
means that RepositoryRef.import
is now Repository.import
. Futhermore, the CDK
Toolkit must also be upgraded since the docker asset protocol was modified.
IRepository.grantUseImage
was renamed to IRepository.grantPull
.addBuildToPipeline
was renamed to addToPipeline
and addTestToPipeline
was renamed to addPipelineToTest
in order to align
with naming conventions.CloudFormationCapabilities.IAM
renamed to
CloudFormation.AnonymousIAM
and PipelineCloudFormationDeployActionProps.capabilities?: CloudFormationCapabilities[]
has been changed to
PipelineCloudFormationDeployActionProps.capabilities?: CloudFormationCapabilities
no longer an array.
PipelineCloudFormationDeployActionProps.fullPermissions?:
has been
renamed to PipelineCloudFormationDeployActionProps.adminPermissions:
and is required instead of optional.<a name="0.18.1"></a>
FAQs
Amazon EventBridge Construct Library
The npm package @aws-cdk/aws-events receives a total of 56,573 weekly downloads. As such, @aws-cdk/aws-events popularity was classified as popular.
We found that @aws-cdk/aws-events demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.